import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../components/Login.vue'
import Home from '../components/Home.vue'
import BuMenGuanLi from '../components/XinXinGuanLi/BuMenGuanLi.vue'
import YuanGongGuanLi from '../components/XinXinGuanLi/YuanGongGuanLi.vue'
import RoleGuanLi from '../components/XinXinGuanLi/RoleGuanLi.vue'
import ResourceGuanLi from '../components/XinXinGuanLi/ResourceGuanLi.vue'
import ImportGuanLi from '../components/XinXinGuanLi/ImportGuanLi.vue'
import test from '../components/XinXinGuanLi/test'
import BanBie from '../components/KaoQinGuanLi/BanBie.vue'
import XiuXi from '../components/KaoQinGuanLi/XiuXi.vue'
import DeptType from '@/components/ShuXingSheZhi/DeptType'
Vue.use(VueRouter)

const routes = [
  {
    path:"/",
    redirect:"/login"//重定向到login页面，即跳转到登录页面
  },
  {
    path:"/login",//登录页面的路由地址
    component: Login
  },
  {
    path:"/home",//首页的路由地址
    component: Home,
    children:[
      {
        path:"/BuMenGuanLi",
        component: BuMenGuanLi
      },
      {
        path:"/YuanGongGuanLi",
        component: YuanGongGuanLi
      },
      {
        path:"/RoleGuanLi",
        component: RoleGuanLi
      },
      {
        path:"/ResourceGuanLi",
        component: ResourceGuanLi
      },
      {
        path:"/ImportGuanLi",
        component: ImportGuanLi
      },
      {
        path:"/test",
        component: test
      },
      {
        path:"/BanBie",
        component: BanBie
      },
      {
        path:"/XiuXi",
        component: XiuXi
      },
      {
        path:"/DeptType",
        component: DeptType
      },
    ]
  }
  
]

const router = new VueRouter({
  routes
})
// 获取原型对象push函数
const originalPush = VueRouter.prototype.push

// 获取原型对象replace函数
const originalReplace = VueRouter.prototype.replace

// 修改原型对象中的push函数
VueRouter.prototype.push = function push(location){
return originalPush.call(this , location).catch(err=>err)
}

// 修改原型对象中的replace函数
VueRouter.prototype.replace = function replace(location){
return originalReplace.call(this , location).catch(err=>err)
}


export default router
